﻿<%@ Page Language="C#" MasterPageFile="~/Masterpages/Default.master" AutoEventWireup="true"
    CodeBehind="ManageTags.aspx.cs" Inherits="Blazing.UI.Cms.Admin.ManageTags" Title="Manage Tags" %>

<%@ Register Assembly="System.BusinessObjects.Framework" Namespace="System.BusinessObjects.Controls"
    TagPrefix="cc1" %>
<%@ Register Src="../Usercontrols/SelectTags.ascx" TagName="SelectTags" TagPrefix="uc1" %>
<%@ Register Assembly="System.Web.Extensions" Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register Src="../Usercontrols/Loading.ascx" TagName="Loading" TagPrefix="uc2" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h1>
        Manage Taxonomies</h1>
    <br />
    <cc2:TabContainer ID="TabContainerMain" runat="server" ActiveTabIndex="0" Width="100%">
        <cc2:TabPanel ID="TabPanel1" runat="server" HeaderText="Taxonomies">
            <HeaderTemplate>
                Taxonomies
            </HeaderTemplate>
            <ContentTemplate>
                <asp:Panel ID="PanelTaxonomies" runat="server" Width="100%">
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <ContentTemplate>
                            <div class="grid">
                                <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
                                    AutoGenerateColumns="False" DataKeyNames="ID,RowState,RowStamp" DataSourceID="odsTaxonomies"
                                    EmptyDataText="There are no taxonomies found" PageSize="50" Width="100%">
                                    <PagerSettings Position="TopAndBottom" />
                                    <Columns>
                                        <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                                        <asp:BoundField DataField="Slug" HeaderText="Slug" SortExpression="Slug" />
                                        <asp:TemplateField HeaderText="Taxonomy Type" SortExpression="TaxonomyType.Name">
                                            <EditItemTemplate>
                                                <asp:DropDownList ID="ddlSelectTaxonomyType" runat="server" DataSourceID="odsTaxonomyTypes"
                                                    DataTextField="Name" DataValueField="ID">
                                                </asp:DropDownList>
                                                <cc1:BindableDropDownListExtender ID="BindableDropDownListExtender1" runat="server"
                                                    AttachTo="ddlSelectTaxonomyType" BoundValue='<%# Bind("TaxonomyType") %>' BoundValueType="Blazing.BusinessObjects.Tagging.TaxonomyType, Blazing.BusinessObjects" />
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="Label1" runat="server" Text='<%# Eval("TaxonomyType.Name") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:CommandField ShowEditButton="True" />
                                    </Columns>
                                </asp:GridView>
                            </div>
                            <asp:ObjectDataSource ID="odsTaxonomies" runat="server" DataObjectTypeName="Blazing.BusinessObjects.Tagging.Taxonomy"
                                DeleteMethod="DeleteTaxonomy" InsertMethod="NewTaxonomy" OldValuesParameterFormatString="original_{0}"
                                SelectMethod="GetSortedTaxonomys" SortParameterName="SortExpression" TypeName="Blazing.WebFacade.TaggingController"
                                UpdateMethod="UpdateTaxonomy" OnInserted="odsTaxonomies_Inserted"></asp:ObjectDataSource>
                            <asp:ObjectDataSource ID="odsTaxonomyTypes" runat="server" OldValuesParameterFormatString="original_{0}"
                                SelectMethod="GetTaxonomyTypes" TypeName="Blazing.WebFacade.TaggingController">
                            </asp:ObjectDataSource>
                            <br />
                            <asp:LinkButton ID="LinkButtonInsertTaxonomy" runat="server">Insert</asp:LinkButton>
                            <br />
                            <cc2:ModalPopupExtender ID="ModalPopupExtender1" runat="server" BackgroundCssClass="PopupPanel"
                                DropShadow="true" PopupControlID="PanelAddTaxonomy" PopupDragHandleControlID="PanelAddTaxonomyTitle"
                                TargetControlID="LinkButtonInsertTaxonomy">
                            </cc2:ModalPopupExtender>
                            <asp:Panel ID="PanelAddTaxonomy" runat="server" CssClass="PopupPanel">
                                <div class="PopupPanelInner" style="width: 300px;">
                                    <asp:Panel ID="PanelAddTaxonomyTitle" runat="server" CssClass="PopupTitle">
                                        Add Taxonomy</asp:Panel>
                                    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" BorderStyle="None"
                                        BorderWidth="0" DataSourceID="odsTaxonomies" DefaultMode="Insert">
                                        <Fields>
                                            <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                                                SortExpression="ID" />
                                            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                                            <asp:BoundField DataField="Slug" HeaderText="Slug" SortExpression="Slug" />
                                            <asp:TemplateField HeaderText="TaxonomyType" SortExpression="TaxonomyType">
                                                <InsertItemTemplate>
                                                    <asp:DropDownList ID="ddlSelectTaxonomyType" runat="server" DataSourceID="odsTaxonomyTypes"
                                                        DataTextField="Name" DataValueField="ID">
                                                    </asp:DropDownList>
                                                    <cc1:BindableDropDownListExtender ID="BindableDropDownListExtender1" runat="server"
                                                        AttachTo="ddlSelectTaxonomyType" BoundValue='<%# Bind("TaxonomyType") %>' BoundValueType="Blazing.BusinessObjects.Tagging.TaxonomyType, Blazing.BusinessObjects" />
                                                </InsertItemTemplate>
                                            </asp:TemplateField>
                                            <asp:CommandField ShowInsertButton="True" />
                                        </Fields>
                                    </asp:DetailsView>
                                </div>
                            </asp:Panel>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </asp:Panel>
            </ContentTemplate>
        </cc2:TabPanel>
        <cc2:TabPanel ID="TabPanel2" runat="server" HeaderText="Taxonomy Tags">
            <ContentTemplate>
                <asp:Panel ID="PanelTaxonomyTags" runat="server" Width="100%">
                    <asp:UpdatePanel ID="UpdatePanelTaxonomyTags" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <div class="Filter">
                                Taxonomy:
                                <asp:DropDownList ID="DropDownListTaxFilter" runat="server" AppendDataBoundItems="True"
                                    DataSourceID="odsTaxonomyFilter" DataTextField="Name" DataValueField="ID">
                                    <asp:ListItem Selected="True" Value="">None</asp:ListItem>
                                </asp:DropDownList>
                                <asp:Button runat="server" Text="Filter" ID="ButtonFilter" OnClick="ButtonFilter_Click" /></div>
                            <div class="grid">
                            
                            <asp:GridView ID="GridViewTaxonomyTags" runat="server" CellPadding="5" GridLines="None"
                                AllowSorting="True" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="ID,RowStamp,RowState"
                                DataSourceID="odsTaxonomyTags" PageSize="35" Width="100%">
                                <PagerSettings Position="TopAndBottom" />
                                <Columns>
                                    <asp:TemplateField HeaderText="Taxonomy" SortExpression="Taxonomy.Name">
                                        <ItemTemplate>
                                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("Taxonomy.Name") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Tag" SortExpression="Tag.Name">
                                        <ItemTemplate>
                                            <asp:Label ID="Label2" runat="server" Text='<%# Eval("Tag.Name") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="ParentTaxonomyTag" SortExpression="ParentTaxonomyTag.InternalName">
                                        <EditItemTemplate>
                                            <asp:DropDownList ID="ddlParentTaxonomyTag" runat="server" DataSourceID="odsTaxonomyTags"
                                                DataTextField="InternalName" DataValueField="ID" AppendDataBoundItems="true">
                                                <asp:ListItem Text="None" Value="" />
                                            </asp:DropDownList>
                                            <cc1:BindableDropDownListExtender ID="BindableDropDownListExtender2" runat="server"
                                                AttachTo="ddlParentTaxonomyTag" BoundValueType="Blazing.BusinessObjects.Tagging.TaxonomyTag, Blazing.BusinessObjects"
                                                BoundValue='<%# Bind("ParentTaxonomyTag") %>' />
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="Label3" runat="server" Text='<%# Eval("ParentTaxonomyTag.InternalName") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="Slug" HeaderText="Slug" SortExpression="Slug" />
                                    <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                                    <asp:CheckBoxField DataField="ChildrenMutuallyExclusive" HeaderText="Children Disjoint"
                                        SortExpression="ChildrenMutuallyExclusive" />
                                    <asp:CheckBoxField DataField="IsSelectable" HeaderText="Selectable" SortExpression="IsSelectable" />
                                    <asp:CheckBoxField DataField="IsVisible" HeaderText="Active" SortExpression="IsVisible" />
                                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                                </Columns>
                            </asp:GridView>
                            </div>
                            <asp:ObjectDataSource ID="odsTaxonomyTags" runat="server" DataObjectTypeName="Blazing.BusinessObjects.Tagging.TaxonomyTag"
                                DeleteMethod="DeleteTaxonomyTag" InsertMethod="NewTaxonomyTag" OldValuesParameterFormatString="original_{0}"
                                SelectMethod="GetTaxonomyTags" TypeName="Blazing.WebFacade.TaggingController"
                                UpdateMethod="UpdateTaxonomyTag" SortParameterName="sortExpression">
                                <SelectParameters>
                                    <asp:ControlParameter ControlID="DropDownListTaxFilter" Name="taxonomyId" PropertyName="SelectedValue" />
                                </SelectParameters>
                            </asp:ObjectDataSource>
                            <asp:ObjectDataSource ID="odsTaxonomyFilter" runat="server" OldValuesParameterFormatString="original_{0}"
                                SelectMethod="GetTaxonomy" TypeName="Blazing.WebFacade.TaggingController"></asp:ObjectDataSource>
                            <br />
                            <uc1:SelectTags ID="SelectTags1" runat="server" AllowAdd="true" />
                            <asp:LinkButton ID="btnAddTags" runat="server" OnClick="btnAddTags_Click">Add</asp:LinkButton>
                            <br />
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </asp:Panel>
            </ContentTemplate>
        </cc2:TabPanel>
    </cc2:TabContainer>
    <br />
    <ajax:UpdateProgress runat="server" ID="update" DisplayAfter="50">
        <ProgressTemplate>
            <uc2:Loading ID="Loading1" runat="server" />
        </ProgressTemplate>
    </ajax:UpdateProgress>
</asp:Content>
